//https://www.luogu.com.cn/problem/P1177
//用堆排序的方法去做
//AC
// 编程语言 C++17
// 代码长度 1.96KB
// 用时 245ms
// 内存 1.00MB
#include<random>
#include<iostream>
#include<vector>
#include<algorithm>

constexpr int ls(int X){return ((X<<1)+1);}
constexpr int rs(int X){return ((X<<1)+2);}
constexpr int fa(int X){return ((X-1)>>1);}



//从大到小
template<typename _RAiter,typename Compare>
void push_down(_RAiter A,int first,int last,Compare less_than){
	using std::swap;
	int r=first;
	while(r<=fa(last)){
		if(ls(r)==last){
			if(less_than(A[ls(r)],A[r])){
				swap(A[r],A[ls(r)]);
			}
			return;
		}
		else if(less_than(A[ls(r)],A[r])&&!less_than(A[rs(r)],A[ls(r)])){
			swap(A[r],A[ls(r)]);
			r=ls(r);
		}
		else if(less_than(A[rs(r)],A[r])&&less_than(A[rs(r)],A[ls(r)])){
			swap(A[r],A[rs(r)]);
			r=rs(r);
		}
		else{return;}
	}
	return;
}

//从小到大
template<typename _RAiter,typename Compare>
void push_down_from_small_to_big(_RAiter A,int first,int last,Compare less_than){
	using std::swap;
	int r=first;
	while(r<=fa(last)){
		if(ls(r)==last){
			if(less_than(A[r],A[ls(r)])){
				swap(A[r],A[ls(r)]);
			}
			return;
		}
		else if(less_than(A[r],A[ls(r)])&&!less_than(A[ls(r)],A[rs(r)])){
			swap(A[r],A[ls(r)]);
			r=ls(r);
		}
		else if(less_than(A[r],A[rs(r)])&&less_than(A[ls(r)],A[rs(r)])){
			swap(A[r],A[rs(r)]);
			r=rs(r);
		}
		else{return;}
	}
	return;
}



template<typename _RAiter,typename Compare>
void my_heap_sort(_RAiter _begin,_RAiter _end, Compare less_than){
	using std::swap;
	const int n=_end-_begin;
	for(int unorder=fa(n-1);unorder>=0;--unorder){
		push_down_from_small_to_big(_begin,unorder,n-1,less_than);			
	}
	for(int i=n-1;i>0;--i){
		swap(_begin[i],_begin[0]);
		push_down_from_small_to_big(_begin,0,i-1,less_than);
	}
}


int main(){
	using namespace std;
	int num,temp;
	cin>>num;
	vector<int> v;
	v.resize(num);
	for(int i=0;i<num;++i){
		cin>>v[i];
	}

	my_heap_sort(v.begin(),v.end(),[](int a,int b){return a<b;});
	for(int i=0;i<num-1;++i){cout<<v[i]<<' ';}
	cout<<v[num-1]<<'\n';
	return 0;
}